/*
 * rewarn_nlist.h
 *
 *  Created on: 2009-5-26
 *      Author: tulai
 */

#ifndef REWARN_NLIST_H_
#define REWARN_NLIST_H_
#include <common/mobilenode.h>

#define MAXNEIGHBORLIST 256
#define MAXRELAY 32

typedef struct node_state {
  double timestamp;
  nsaddr_t addr_ ;
  double posx;
  double  posy;
  double velocity;
  double yaw;
  double accx;
  double accy;
  double ttx;
  nsaddr_t tar_addr;
} node_state_t;

typedef struct relaylist {
  nsaddr_t party1;
  nsaddr_t party2;
  double abstime;
  relaylist *next;
  relaylist *pre;
} relaylist_t;

//typedef struct state_list_node {
//  unsigned double timestamp;
//  nsaddr_t addr_ ;
//  u_int16_t posx;
//  u_int16_t  posy;
//  double velocity;
//  double yaw;
//  double accx;
//  double accy;
//  unsigned double ttx;
//  nsaddr_t tar_addr;
//  state_list_node* next_;
//} state_list_node_t;



class rewarn_nlist {

public:
  node_state_t nlist[MAXNEIGHBORLIST];
  u_int16_t size_;
  rewarn_nlist();

public:
  //list operation
  //===========================================
  //neighborlist related
  //node_state_t* get(int index)
  //void remove(int index)
  //int find_node_by_address(nsaddr_t)
  //node_state_t* get_node_by_address(nsaddr_t)
  //int getsize()
  //void insert(node_state_t )

  void remove(u_int16_t index);
  void insert(node_state_t node_state_);
  int find_node_by_address(nsaddr_t addr_);
  node_state_t* get(u_int16_t index);
  u_int16_t getsize();
  bool isfull();


};

class rewarn_rlist {
public:
  rewarn_rlist();
  relaylist_t * rhead;

  u_int16_t size;

public:
  void insert(nsaddr_t party1, nsaddr_t party2, double abstime);
  int find(nsaddr_t party1, nsaddr_t party2);
  int remove(nsaddr_t party1, nsaddr_t party2);
  void removehead();


};

#endif /* REWARN_NLIST_H_ */
